package com.lianrui.commons.exception;

import org.slf4j.Logger;

import com.lianrui.message.SystemMessageFactory;

/**
 * 功能描述：系统异常类
 *
 * @author LJQ
 *
 * 2015年12月28日 下午3:58:16
 */
public class SystemException extends RuntimeException {

	private static final long serialVersionUID = -1L;

	private int code;

	@Deprecated
	protected SystemException() {
		super();
	}

	@Deprecated
	protected SystemException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
		super(message, cause, enableSuppression, writableStackTrace);
	}

	@Deprecated
	protected SystemException(String message, Throwable cause) {
		super(message, cause);
	}

	@Deprecated
	protected SystemException(String message) {
		super(message);
	}

	@Deprecated
	protected SystemException(Throwable cause) {
		super(cause);
	}

	public SystemException(int code, Logger logger, Object... params) {
		super(SystemMessageFactory.formatMessage(code, params));
		logger.error(SystemMessageFactory.formatMessage(code, params));
		this.code = code;
	}

	public SystemException(int code, Logger logger, Throwable cause, Object... params) {
		super(SystemMessageFactory.formatMessage(code, params), cause);
		logger.error(SystemMessageFactory.formatMessage(code, params));
		this.code = code;
	}
	
	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}
	
}
